package com.acwing.partition43;

import java.io.*;

/**
 * @author rkc
 * @date 2022/7/27 9:17
 */
public class AC4266无线网络 {

    private static final int N = 1010;
    private static int[][] p = new int[N][2];
    private static int[] parent = new int[N];
    private static boolean[] st = new boolean[N];
    private static int n, m;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]); m = Integer.parseInt(ss[1]);
        for (int i = 1; i <= n; i++) {
            parent[i] = i;
            ss = reader.readLine().split(" ");
            p[i] = new int[] {Integer.parseInt(ss[0]), Integer.parseInt(ss[1])};
        }
        while (true) {
            String s = reader.readLine();
            if (s == null || s.isEmpty()) break;
            ss = s.split(" ");
            int p = Integer.parseInt(ss[1]);
            if (ss[0].equals("O")) {
                st[p] = true;
                for (int i = 1; i <= n; i++) {
                    if (st[i] && i != p && calc(p, i) <= m) {
                        parent[find(p)] = i;
                    }
                }
            } else if (ss[0].equals("S")) {
                int q = Integer.parseInt(ss[2]);
                writer.write(find(p) == find(q) ? "SUCCESS\n" : "FAIL\n");
            }
        }
        writer.flush();
    }

    private static int find(int x) {
        if (x != parent[x]) parent[x] = find(parent[x]);
        return parent[x];
    }

    private static double calc(int i, int j) {
        int x1 = p[i][0], y1 = p[i][1], x2 = p[j][0], y2 = p[j][1];
        return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    }
}
